package io.renren.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import io.renren.entity.EslRefreshResultEntity;
import io.renren.service.EslRefreshResultService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 墨水屏刷新结果
 *
 * @author 1
 * @email 1@2.com
 * @date 2022-01-21 22:41:53
 */
@RestController
@RequestMapping("/eslrefreshresult")
public class EslRefreshResultController {
    @Autowired
    private EslRefreshResultService eslRefreshResultService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions(":eslrefreshresult:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = eslRefreshResultService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions(":eslrefreshresult:info")
    public R info(@PathVariable("id") Long id) {
        EslRefreshResultEntity eslRefreshResult = eslRefreshResultService.getById(id);

        return R.ok().put("eslRefreshResult", eslRefreshResult);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions(":eslrefreshresult:save")
    public R save(@RequestBody EslRefreshResultEntity eslRefreshResult) {
        eslRefreshResultService.save(eslRefreshResult);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions(":eslrefreshresult:update")
    public R update(@RequestBody EslRefreshResultEntity eslRefreshResult) {
        ValidatorUtils.validateEntity(eslRefreshResult);
        eslRefreshResultService.updateById(eslRefreshResult);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions(":eslrefreshresult:delete")
    public R delete(@RequestBody Long[] ids) {
        eslRefreshResultService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
